package com.blank.task18;

import java.util.List;

public class DelStudent {
    public static void Delete(int stuNum, List<Student> studentList){
        //遍历studentList集合查找与id相匹配的索引值,再将其删去
        for(Student stu:studentList){
            //获取索引值
            int index = studentList.indexOf(stu);
            if(stuNum == stu.getStuNumber()){
                //将该id对应的索引值移除,实现删除操作
                studentList.remove(index);
                System.out.println("删除成功!");


            }
        }
    }
}
